<template>
  <div>
    <h3>主页</h3>
    {{type}}
    <table style="width:800px; margin:0 auto">
        <tr>
            <td>编号</td>
            <td>文章名</td>
        </tr>
        <tr v-for="(item,i) in type" :key="i">
            <td>{{item.id}}</td>
            <td>
                <router-link :to="({name:'Article',params:{id:item.id} })">{{item.name}}</router-link>
            </td>
        </tr>
    </table>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            type:[]
        }
    },
    mounted(){
        this.getType()
    },
    methods:{
        getType(){
            axios.get('type/')
            .then(resp=>{
                console.log(resp);
                this.type=resp.data
            })
            .catch(err=>{
                console.log(err);
            })
        }
    }
}
</script>

<style>

</style>